package com.azhoucode.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @description: 模板类型
 * @author: azhou
 * @create: 2021-12-14 15:58
 **/
@Getter
@AllArgsConstructor
public enum TemplateTypeEnum {

    APPLICATION(1, "application.ftl", "application.yml"),
    ENTITY(2, "entity.ftl", "%s.java"),
    CONTROLLER(3, "controller.ftl", "%sController.java"),
    SERVICE(4, "service.ftl", "%sService.java"),
    SERVICE_IMPL(5, "serviceImpl.ftl", "%sServiceImpl.java"),
    DAO(6, "dao.ftl", "%sDao.java"),
    DTO(7, "dto.ftl", "%sDTO.java"),
    POM(8, "pom.ftl", "pom.xml"),
    XML(9, "xml.ftl", "%sDao.xml"),
    REDIS_CONFIG(10, "redisConfig.ftl", "RedisConfig.java"),
    REDIS_UTIL(11, "redisUtil.ftl", "RedisUtil.java"),
    MAIN_UTIL(12, "mailUtil.ftl", "MailUtil.java"),
    LOGIN_CONTROLLER(13, "loginController.ftl", "LoginController.java"),
    VUE_TABLE(14, "vueTable.ftl", "index.vue"),
    VUE_API(15, "api.ftl", "index.js"),
    VUE_ROUTER(16, "sysRouter.ftl", "index.js"),
    VUE_TABLE2(17, "vueTable2.ftl", "%s.vue"),
    VUE_ROUTER2(18, "sysRouter2.ftl", "index.js"),
    VUE_SIDEBAR(19, "Sidebar.ftl", "Sidebar.vue"),
    VUE_ROUTER3(20, "admin.ftl", "admin.json"),

    ;

    private Integer type;

    /**
     * 模板文件名称
     */
    private String ftlName;

    /**
     * 模板生成文件名称,使用占位符的形式
     */
    private String fileName;

    public static TemplateTypeEnum getByCode(Integer code) {
        for (TemplateTypeEnum templateTypeEnum : TemplateTypeEnum.values()) {
            if(templateTypeEnum.getType().equals(code)) {
                return templateTypeEnum;
            }
        }
        return null;
    }



}
